package com.lottery.im.module.result.adapter.result.statistics;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import java.util.List;

public class DoubleLotteryAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
  private String[] titleArr =
      { "号码出现次数", "第一球", "第二球", "第三球", "第四球", "第五球", "总和" };
  private int[] colorArr =
      {
          R.color.pk4_fc9030,
          R.color.pk2_5ba9f8,
          R.color.pk3_6a6a6a,
          R.color.pk3_6a6a6a,
          R.color.pk3_6a6a6a,
          R.color.pk3_6a6a6a
      };

  public DoubleLotteryAdapter(@Nullable List<String> data) {
    super(R.layout.item_double_statistics_list, data);
  }

  @Override protected void convert(final BaseViewHolder helper, String item) {
    TextView mTvTitle = helper.getView(R.id.tv_title);
    mTvTitle.setText(titleArr[helper.getAdapterPosition()]);
    mTvTitle.setBackgroundColor(
        mContext.getResources().getColor(colorArr[helper.getAdapterPosition()]));
    View mLayoutName = helper.getView(R.id.layout_name);
    View mLayoutNum = helper.getView(R.id.layout_num);

    TextView mTvName1 = helper.getView(R.id.tv_name1);
    TextView mTvName2 = helper.getView(R.id.tv_name2);
    TextView mTvName3 = helper.getView(R.id.tv_name3);
    TextView mTvName4 = helper.getView(R.id.tv_name4);

    TextView mTvNum1 = helper.getView(R.id.tv_num1);
    TextView mTvNum2 = helper.getView(R.id.tv_num2);
    TextView mTvNum3 = helper.getView(R.id.tv_num3);
    TextView mTvNum4 = helper.getView(R.id.tv_num4);
    TextView mTvNum5 = helper.getView(R.id.tv_num5);
    TextView mTvNum6 = helper.getView(R.id.tv_num6);
    TextView mTvNum7 = helper.getView(R.id.tv_num7);
    TextView mTvNum8 = helper.getView(R.id.tv_num8);
    TextView mTvNum9 = helper.getView(R.id.tv_num9);
    TextView mTvNum10 = helper.getView(R.id.tv_num10);
    if (item.contains(",")) {
      String[] str = item.split(",");
      if (helper.getAdapterPosition() == 0) {
        mLayoutName.setVisibility(View.VISIBLE);
        mLayoutNum.setVisibility(View.VISIBLE);
        mTvName1.setText("0");
        mTvName2.setText("1");
        mTvName3.setText("2");
        mTvName4.setText("3");
        if (str.length > 9) {
          mTvNum1.setText(str[0]);
          mTvNum2.setText(str[1]);
          mTvNum3.setText(str[2]);
          mTvNum4.setText(str[3]);
          mTvNum5.setText(str[4]);
          mTvNum6.setText(str[5]);
          mTvNum7.setText(str[6]);
          mTvNum8.setText(str[7]);
          mTvNum9.setText(str[8]);
          mTvNum10.setText(str[9]);
        }
      } else {
        mLayoutName.setVisibility(View.GONE);
        mLayoutNum.setVisibility(View.GONE);
        mTvName1.setText("大");
        mTvName2.setText("小");
        mTvName3.setText("单");
        mTvName4.setText("双");
        if (str.length > 3) {
          mTvNum1.setText(str[0]);
          mTvNum2.setText(str[1]);
          mTvNum3.setText(str[2]);
          mTvNum4.setText(str[3]);
        }
      }
    }
  }
}
